<!DOCTYPE html>
<html lang="zh">
<head>
    <title><{:isset($webConf.bs_title)?$webConf.bs_title:'BS后台管理'}></title>
    <{include file="public/header"}>
    <{include file="public/data_tables_css"}>

</head>
<body class="hold-transition sidebar-mini layout-fixed">
<!-- Site wrapper -->
<div class="wrapper">
    <!-- Navbar -->
    <{include file="public/navbar"}>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <!--左侧菜单-->
    <{include file="public/sidebar"}>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1></h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="<{:url('/admin/index/index')}>">首页</a></li>
                            <li class="breadcrumb-item"><a href="<{:url('/admin/merchant.index/index')}>">商户中心</a></li>
                            <li class="breadcrumb-item active">提现申请</li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>

        <section class="content">
            <div class="container-fluid">
                <div class="card">
                    <div class="card-header">
                        <form action="<{:url()}>">
                            <div class="form-row ">
                                <div class="col-auto">
                                    <select name="status" class="form-control " >
                                        <option  value="">全部状态</option>
                                        <option <{if null !== $Request.param.status &&$Request.param.status=='1'}>selected<{/if}>  value="1">已通过</option>
                                        <option <{if null !== $Request.param.status &&$Request.param.status=='0'}>selected<{/if}> value="0">待审核</option>
                                        <option <{if null !== $Request.param.status &&$Request.param.status=='-1'}>selected<{/if}> value="-1">已驳回</option>
                                    </select>
                                </div>

                                <div class="col-auto">

                                    <input name="keyword" type="text" class="form-control " placeholder="单号/姓名/收款账号" value="">
                                </div>

                                <div class="col-auto">
                                    <button type="submit" class="btn btn-primary mb-2 "><i class="fas fa-search"></i></button>
                                </div>
                            </div>
                        </form>

                    </div>
                    <div class="card-body">
                        <table id="my_table" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>商家</th>
                                <th>单号</th>
                                <th>状态</th>
                                <th>申请金额</th>
                                <th>手续费</th>
                                <th>途径</th>
                                <th>说明</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>


                            <{if !empty($data)}>
                            <{foreach $data as $item}>
                            <tr>
                                <td>
                                    <{if $item.merchant}>
                                    <a title="查看货款记录" href="<{:url('/admin/merchant.finance/index',['keyword'=>$item.merchant.account])}>"><{$item.merchant.user_name}>(<{$item.merchant.account}>)</a>
                                    <{else}>
                                    已注销
                                    <{/if}>

                                </td>
                                <td><{$item.order_no}></td>
                                <td>
                                    <{$item.status_desc}>
                                </td>
                                <td><{$item.num}></td>
                                <td><{$item.fee}></td>
                                <td>
                                    姓名：<{$item.username}> <br>
                                    <{$item.to_type_desc}>：<{$item.to_account}>
                                </td>
                                <td class="bs-red">
                                    <{if $item.status==-1}>
                                    <{$item.fail_text?$item.fail_text:''}>
                                    <{elseif $item.status==1 && !empty($item.imgs)}>
                                    <span class="btn btn-success" onclick="view_pic(this)" data-imgs="<{$item.imgs}>"> 查看凭证</span>
                                    <{/if}>


                                </td>
                                <td>
                                    申请：<{$item.add_time}> <br>

                                    审核：<{if $item.status<>0}>
                                    <{$item.up_time}>
                                    <{else}>
                                    待审核
                                    <{/if}>
                                </td>
                                <td>
                                    <{if $item.status==0}>
                                    <span data-sn="<{$item.order_no}>" data-money="<{$item.num}>"  data-fee="<{$item.fee}>" data-name="<{$item.username}>"  data-account="<{$item.to_account}>" data-totype="<{$item.to_type_desc}>"  class="btn btn-sm  btn-warning " onclick="check_modal(this)" >审核</span>
                                    <{/if}>


                                </td>
                            </tr>
                            <{/foreach}>
                            <{/if}>



                            </tbody>
                            <tfoot>


                            </tfoot>
                        </table>
                    </div>
                    <div class="card-footer">
                        <{$page?$page->render():''}>
                    </div>
                    <!-- /.card-body -->
                </div>
            </div>
        </section>

        <div class="bs-model">

            <div class="modal fade" id="modal-check">
                <div class="modal-dialog">
                    <form action="<{:url('withdraw_action')}>" method="post" id="check-form">
                        <div class="hidden">
                            <input type="hidden" name="order_sn" class="order_sn">
                        </div>
                        <div class="modal-content">
                            <div class="modal-header">
                                <h4 class="modal-title">提现申请审核</h4>
                                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                    <span aria-hidden="true">&times;</span>
                                </button>
                            </div>
                            <div class="modal-body">
                                <div class="alert alert-danger">
                                    <p>为了更安全，目前采用线下转账方式，需要线上转账请联系微信（woyekeha)定制开发，请先手动转账后上传凭证便于证明。</p>
                                    姓名：<span class="a-name"></span><br>
                                    类型：<span class="a-totype"></span><br>
                                    账号：<span class="a-account"></span><br>
                                    金额：<span class="a-money"></span><br>
                                    手续费：<span class="a-fee"></span>
                                </div>
                                <div class="form-group">
                                    <label for="astatus">处理为</label>
                                    <select name="astatus" id="astatus" class="form-control">
                                        <option value="0">请选择</option>
                                        <option value="1">已转账</option>
                                        <option value="-1">驳回</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label for="img">凭证</label>
                                    <input type="file" name="img" accept=".img,.jpg,.jpeg,.png" id="img">
                                    <br>
                                    <span class="bs-red">
                                        转账的凭证，可选上传
                                    </span>
                                </div>
                                <div class="form-group">
                                    <label for="fail_text">驳回理由</label>
                                    <textarea name="fail_text" placeholder="驳回必须填写理由" id="fail_text" class="form-control"></textarea>
                                </div>
                            </div>
                            <div class="modal-footer justify-content-between">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="button" onclick="w_action()" class="btn btn-primary">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /.content-wrapper -->

    <{include file="public/copyright"}>


</div>
<!-- ./wrapper -->

<{include file="public/footer"}>
<!-- DataTables  & Plugins -->
<{include file="public/data_tables"}>
<script>

    function view_pic(obj){
        var src = $(obj).data('imgs');
        var wh = window.innerWidth;
        var w = '500px';
        if (wh<600){
            w = '100%'
        }
        layer.open({
            title: '转账凭证',
            area:[w,'600px'],
            content:"<div><img style='max-width: 100%' src='"+src+"'></div>"
        })
    }

    function w_action(){
        var status = $("select[name='astatus'] option:selected").val();
        var failText = trim($("textarea[name='fail_text']").val());
        if (!status){
            return layer.msg('请选择处理状态')
        }
        if (status==-1){
            if (failText.length<10){
                return layer.msg('请填写驳回原因,且不能小于10个字')
            }

        }
        layer.confirm("确定"+(status==1?'已经转账了':'要驳回申请')+"吗",{title:'不可回撤操作提示'},function () {
            form_submit([],"<{:url()}>",false,function (res) {
                if (res.code==0){
                    $("#modal-check").modal('hide')
                }
            });
        })


    }

    function check_modal(obj){
        $("textarea[name='fail_text']").val('');
        document.getElementById('astatus').selectedIndex = 0;
        $(".a-name").text($(obj).data('name'));
        $(".a-fee").text($(obj).data('fee'));
        $(".a-money").text($(obj).data('money'));
        $(".a-account").text($(obj).data('account'));
        $(".a-totype").text($(obj).data('totype'));
        $("input[name='order_sn']").val($(obj).data('sn'))
        $("#modal-check").modal('show');
    }



    $(function () {
        $("#my_table").DataTable({
            "ordering": false,//禁用排序
            "responsive": true,
            "lengthChange": false,
            "autoWidth": false,
            //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
            // "pageLength": 10,         //初始化显示几条数据
            //serverSide: true, // use local process instead of server
            bFilter: false, // show top right search input box.
            bPaginate: false,//是否开启分页
            //iDisplayLength: 10, //默认显示的记录数
            bInfo: false,//是否显示页脚信息，DataTables插件左下角显示记录数
        }).buttons().container().appendTo('#my_table_wrapper .col-md-6:eq(0)');

    });
</script>
</body>
</html>
